<?php
/*
 * Shop online & eStore
 *
 * Author: mr.Trieu
 * Created: 22-11-2011
 * $shop.php
 *
 * */
if (!defined('IN_DISCUZ')){
	exit('Access Denied');
}

global $_G;

$sid = isset($_G['gp_sid']) ? intval($_G['gp_sid']) : 0;
$attr = isset($_G['gp_attr']) ? strval($_G['gp_attr']) : '';
$name = isset($_G['gp_name']) ? strval($_G['gp_name']) : '';

list($navtitle, $metadescription, $metakeywords) = get_seosetting('shop');

if (!$navtitle){
	$navtitle = $_G['setting']['navs'][132]['navname'];
	$nobbname = false;
}else
	$nobbname = true;

if (!$metadescription)
	$metadescription = $navtitle;

if (!$metakeywords)
	$metakeywords = $navtitle;

if (!$sid && !$name){

	extract(get_memory_cached('SHOP_MEMORY'));
	if (defined('SHOP_MEMORY') && SHOP_MEMORY){
		include template('shop/shop_index');
		dexit();
	}

	// San pham gia shock
	$spShock = spShockIndex(5);
	// San pham moi nhat
	$spNew = spNew(4);
	// San pham noi bat nhat
	$spHot = spHot(4);
	// San pham gia tot moi ngay
	$spGT = spBestPrice(4);
	// Check History view
	if ($_G['uid']){
		$allWeek = checkProViewCookie('all');
	}

	/*
	 * Check memory cache
	 * for memcached
	 * */
	if (memory('check') && !SHOP_MEMORY){
		$nextpdate = 900;
		memory('set', 'SHOP_MEMORY', array(
//				'wooProducts'=>$wooProducts
		), $nextpdate);
	}

	include template('shop/shop_index');
}elseif (!$sid && $name == 'all-categories')
	require libfile('shop/categories_all', 'include');
elseif (!$sid && $name == 'bestday-products')
	require libfile('shop/categories_bestday', 'include');
elseif (!$sid && $name == 'bestsale-products')
	require libfile('shop/categories_bestsale', 'include');
elseif (!$sid && $name == 'hot-products')
	require libfile('shop/categories_hot', 'include');
elseif (!$sid && $name == 'new-products')
	require libfile('shop/categories_new', 'include');
elseif (!$sid && $name == 'hotdeal-products')
	require libfile('shop/categories_hotdeal', 'include');
else
	require libfile('shop/categories', 'include');